//
//  WebExtraction.h
//  WebClipper
//
//  Created by Daniel Braun on 24/02/07.
//  Copyright 2007 Daniel Braun http://page-appart.net, http://braun.daniel.free.fr All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "WCDom.h"

@interface WCWebExtractionPath : NSObject {
	NSMutableArray *extractionPath;
#ifdef DOXYGEN
	_WebExtractionPathItem *__extractionPath;
#endif
	DOMNode *top;
}

+ (WCWebExtractionPath *) webExtractionPathForNode:(DOMNode *)n;
- initWithNode:(DOMNode *)n;
- (void) buildPathFor:(DOMNode *)n;
- (void) _buildPathFor:(DOMNode *)n; //private

- (DOMHTMLElement *)extractFrom:(DOMHTMLElement *)n;

- (NSArray *) extractionPath;
- (NSString *) jsCode;


@end



@interface _WebExtractionPathItem : NSObject {
	BOOL active;
	BOOL sameLevel;
	BOOL activeCanBeChanged;
	NSString *nodeName;
	NSString *idName;
	NSString *classNam;
	int occurence;
	DOMNode *parent;
	DOMNode *domNode;
	int specialAction;
	NSString *matchString;
	BOOL match;
}
- (NSString *) jsCode;
+ (_WebExtractionPathItem *) webExtractionWithName:(NSString *)nn 
					    idName:(NSString *)ni
					 className:(NSString *)nc
					    parent:(DOMNode *)p
					      node:(DOMNode *)n;
- (NSNumber *) noccurence;
- (void) setOccurence:(int)n;
- (void) setNoccurence:(NSNumber *)n;

- (DOMNode *) domNode;
- (BOOL) active;
- (void) setActive:(BOOL)v;
- (BOOL) sameLevel;
- (void) setSameLevel:(BOOL)v;
- (void) setSameLevel:(BOOL)v notify:(BOOL)notif;
- (BOOL) activeCanBeChanged;
- (void) setActiveCanBeChanged:(BOOL)v;
- (DOMHTMLElement *)extractFrom:(DOMHTMLElement *)n;


- (NSArray *) possibleSpecialActions;
- (int) specialAction;
- (void) setSpecialAction:(int)v;
@end


@protocol _WebExtractionPathItemMayImplement
/*
 * method that may be implemented as category
 */
- (void) _updated;

@end

